﻿USE [eBookLib]
GO
/****** Object:  Table [dbo].[Author]    Script Date: 08/09/2011 21:40:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Author](
	[AuthorID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](250) NULL,
	[DateOfBirth] [smalldatetime] NULL,
	[DateOfDeath] [smalldatetime] NULL,
	[Version] [int] NOT NULL,
 CONSTRAINT [PK_Author] PRIMARY KEY CLUSTERED 
(
	[AuthorID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Topic]    Script Date: 08/09/2011 21:40:04 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Topic](
	[TopicID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](250) NOT NULL,
 CONSTRAINT [PK_Topic] PRIMARY KEY CLUSTERED 
(
	[TopicID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Publisher]    Script Date: 08/09/2011 21:40:04 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Publisher](
	[PublisherID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](250) NULL,
	[ISBNChunk] [varchar](50) NULL,
	[DateCreated] [smalldatetime] NULL,
	[DateModified] [smalldatetime] NULL,
	[Version] [int] NOT NULL,
 CONSTRAINT [PK_Publisher] PRIMARY KEY CLUSTERED 
(
	[PublisherID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Category]    Script Date: 08/09/2011 21:40:04 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Category](
	[CategoryID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](50) NULL,
 CONSTRAINT [PK_Category] PRIMARY KEY CLUSTERED 
(
	[CategoryID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Book]    Script Date: 08/09/2011 21:40:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Book](
	[BookID] [int] IDENTITY(1,1) NOT NULL,
	[ISBN10] [varchar](50) NULL,
	[ISBN13] [varchar](50) NULL,
	[ASIN] [varchar](50) NULL,
	[DeweyDecimal] [varchar](50) NULL,
	[LCCN] [varchar](50) NULL,
	[Title] [varchar](250) NULL,
	[Subtitle] [varchar](250) NULL,
	[PublisherID] [int] NULL,
	[NumberOfPages] [int] NULL,
	[Edition] [varchar](50) NULL,
	[AmazonRating] [varchar](50) NULL,
	[EditorialReview] [varchar](7000) NULL,
	[PublicationDate] [varchar](50) NULL,
	[SmallImageURL] [varchar](250) NULL,
	[MediumImageURL] [varchar](250) NULL,
	[LargeImageURL] [varchar](250) NULL,
	[FilePath] [varchar](250) NULL,
	[FileName] [varchar](250) NULL,
	[DateCreated] [smalldatetime] NULL,
	[DateModified] [smalldatetime] NULL,
	[Version] [int] NOT NULL,
 CONSTRAINT [PK_Book] PRIMARY KEY CLUSTERED 
(
	[BookID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Link]    Script Date: 08/09/2011 21:40:04 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Link](
	[LinkID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](100) NULL,
	[Path] [varchar](250) NULL,
	[BookID] [int] NULL,
	[DateCreated] [smalldatetime] NULL,
	[DateModified] [smalldatetime] NULL,
	[Version] [int] NOT NULL,
 CONSTRAINT [PK_Link] PRIMARY KEY CLUSTERED 
(
	[LinkID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[BookTopic]    Script Date: 08/09/2011 21:40:04 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[BookTopic](
	[BookTopicID] [int] IDENTITY(1,1) NOT NULL,
	[BookID] [int] NULL,
	[TopicID] [int] NULL,
 CONSTRAINT [PK_BookTopic] PRIMARY KEY CLUSTERED 
(
	[BookTopicID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[BookCategory]    Script Date: 08/09/2011 21:40:04 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[BookCategory](
	[BookCategoryID] [int] IDENTITY(1,1) NOT NULL,
	[BookID] [int] NULL,
	[CategoryID] [int] NULL,
 CONSTRAINT [PK_BookCategory] PRIMARY KEY CLUSTERED 
(
	[BookCategoryID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[BookAuthor]    Script Date: 08/09/2011 21:40:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[BookAuthor](
	[BookAuthorID] [int] IDENTITY(1,1) NOT NULL,
	[BookID] [int] NULL,
	[AuthorID] [int] NULL,
 CONSTRAINT [PK_BookAuthor] PRIMARY KEY CLUSTERED 
(
	[BookAuthorID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Default [DF_Author_Version]    Script Date: 08/09/2011 21:40:03 ******/
ALTER TABLE [dbo].[Author] ADD  CONSTRAINT [DF_Author_Version]  DEFAULT ((1)) FOR [Version]
GO
/****** Object:  Default [DF_Book_Version]    Script Date: 08/09/2011 21:40:03 ******/
ALTER TABLE [dbo].[Book] ADD  CONSTRAINT [DF_Book_Version]  DEFAULT ((1)) FOR [Version]
GO
/****** Object:  Default [DF_Link_Version]    Script Date: 08/09/2011 21:40:04 ******/
ALTER TABLE [dbo].[Link] ADD  CONSTRAINT [DF_Link_Version]  DEFAULT ((1)) FOR [Version]
GO
/****** Object:  Default [DF_Publisher_Version]    Script Date: 08/09/2011 21:40:04 ******/
ALTER TABLE [dbo].[Publisher] ADD  CONSTRAINT [DF_Publisher_Version]  DEFAULT ((1)) FOR [Version]
GO
/****** Object:  ForeignKey [FK_Book_Publisher]    Script Date: 08/09/2011 21:40:03 ******/
ALTER TABLE [dbo].[Book]  WITH CHECK ADD  CONSTRAINT [FK_Book_Publisher] FOREIGN KEY([PublisherID])
REFERENCES [dbo].[Publisher] ([PublisherID])
GO
ALTER TABLE [dbo].[Book] CHECK CONSTRAINT [FK_Book_Publisher]
GO
/****** Object:  ForeignKey [FK_BookAuthor_Author]    Script Date: 08/09/2011 21:40:03 ******/
ALTER TABLE [dbo].[BookAuthor]  WITH CHECK ADD  CONSTRAINT [FK_BookAuthor_Author] FOREIGN KEY([AuthorID])
REFERENCES [dbo].[Author] ([AuthorID])
GO
ALTER TABLE [dbo].[BookAuthor] CHECK CONSTRAINT [FK_BookAuthor_Author]
GO
/****** Object:  ForeignKey [FK_BookAuthor_Book]    Script Date: 08/09/2011 21:40:03 ******/
ALTER TABLE [dbo].[BookAuthor]  WITH CHECK ADD  CONSTRAINT [FK_BookAuthor_Book] FOREIGN KEY([BookID])
REFERENCES [dbo].[Book] ([BookID])
GO
ALTER TABLE [dbo].[BookAuthor] CHECK CONSTRAINT [FK_BookAuthor_Book]
GO
/****** Object:  ForeignKey [FK_BookCategory_Book]    Script Date: 08/09/2011 21:40:04 ******/
ALTER TABLE [dbo].[BookCategory]  WITH CHECK ADD  CONSTRAINT [FK_BookCategory_Book] FOREIGN KEY([BookID])
REFERENCES [dbo].[Book] ([BookID])
GO
ALTER TABLE [dbo].[BookCategory] CHECK CONSTRAINT [FK_BookCategory_Book]
GO
/****** Object:  ForeignKey [FK_BookCategory_Category]    Script Date: 08/09/2011 21:40:04 ******/
ALTER TABLE [dbo].[BookCategory]  WITH CHECK ADD  CONSTRAINT [FK_BookCategory_Category] FOREIGN KEY([CategoryID])
REFERENCES [dbo].[Category] ([CategoryID])
GO
ALTER TABLE [dbo].[BookCategory] CHECK CONSTRAINT [FK_BookCategory_Category]
GO
/****** Object:  ForeignKey [FK_BookTopic_Book]    Script Date: 08/09/2011 21:40:04 ******/
ALTER TABLE [dbo].[BookTopic]  WITH CHECK ADD  CONSTRAINT [FK_BookTopic_Book] FOREIGN KEY([BookID])
REFERENCES [dbo].[Book] ([BookID])
GO
ALTER TABLE [dbo].[BookTopic] CHECK CONSTRAINT [FK_BookTopic_Book]
GO
/****** Object:  ForeignKey [FK_BookTopic_Topic]    Script Date: 08/09/2011 21:40:04 ******/
ALTER TABLE [dbo].[BookTopic]  WITH CHECK ADD  CONSTRAINT [FK_BookTopic_Topic] FOREIGN KEY([TopicID])
REFERENCES [dbo].[Topic] ([TopicID])
GO
ALTER TABLE [dbo].[BookTopic] CHECK CONSTRAINT [FK_BookTopic_Topic]
GO
/****** Object:  ForeignKey [FK_Link_Book]    Script Date: 08/09/2011 21:40:04 ******/
ALTER TABLE [dbo].[Link]  WITH CHECK ADD  CONSTRAINT [FK_Link_Book] FOREIGN KEY([BookID])
REFERENCES [dbo].[Book] ([BookID])
GO
ALTER TABLE [dbo].[Link] CHECK CONSTRAINT [FK_Link_Book]
GO
